package com.twu.biblioteca.user;

/**
 * Created by mderaldo on 9/30/14.
 */
public class User {

    private String name;
    private String address;
    private String phoneNumber;
    private String username;
    private String password;
    private UserFormat userFormat;

    public User(String username, String password, String name, String address, String phoneNumber){
        this.password = password;
        this.username = username;
        this.name = name;
        this.address = address;
        this.phoneNumber = phoneNumber;
        userFormat = new UserFormat();
    }

    public String getUsername(){
        return username;
    }

    public String getPassword(){
        return password;
    }

    public String getDetail(){
        return "Name: " + name + " |" +
                "Address: " + address + " |" +
                "Phone Number: " + phoneNumber;
    }

    public boolean isUsernameValid(String username) {
        boolean isUsernameValid;
        try{
            userFormat.verifyUsernameFormat(username);
            isUsernameValid = true;
        }catch (UserNameInvalidException e) {
            isUsernameValid = false;
        }
        return isUsernameValid;
    }
}
